package com.sui.bigdata.flink.sql.sink.message.table;

import com.sui.bigdata.flink.sql.core.table.AbsTableParser;
import com.sui.bigdata.flink.sql.core.table.TableInfo;
import com.sui.bigdata.flink.sql.core.util.MathUtil;

import java.util.Map;

/**
 * @author YongChen
 * @date 2020/3/3 10:46
 * @description
 * @email yong_chen@sui.com
 */
public class MessageSinkParser extends AbsTableParser {

    @Override
    public TableInfo getTableInfo(String tableName, String fieldsInfo, Map<String, Object> props) throws Exception {
        MessageSinkTableInfo messageSinkTableInfo = new MessageSinkTableInfo();
        messageSinkTableInfo.setName(tableName);
        parseFieldsInfo(fieldsInfo, messageSinkTableInfo);

        messageSinkTableInfo.setPhone(MathUtil.getString(props.get(MessageSinkTableInfo.PHONE.toLowerCase())));
        messageSinkTableInfo.setTemplate(MathUtil.getString(props.get(MessageSinkTableInfo.TEMPLATE.toLowerCase())));
        messageSinkTableInfo.check();
        return messageSinkTableInfo;
    }
}
